﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace C4F.DevKit.Bluetooth.ServiceAndDeviceDiscovery
{
    /// <summary>
    /// Represents the WsaProtocolInfo structure.
    /// </summary>
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    public class WsaProtocolInfo
    {
        /// <summary>
        /// Bitmask describing the services provided by the protocol.
        /// </summary>
        public uint ServiceFlags1;
        /// <summary>
        /// Reserved for additional protocol-attribute definitions.
        /// </summary>
        public uint ServiceFlags2;
        /// <summary>
        /// Reserved for additional protocol-attribute definitions.
        /// </summary>
        public uint ServiceFlags3;
        /// <summary>
        /// Reserved for additional protocol-attribute definitions.
        /// </summary>
        public uint ServiceFlags4;
        /// <summary>
        /// Provides information about how this protocol is represented
        /// in the protocol catalog. 
        /// </summary>
        public uint ProviderFlags;
        /// <summary>
        /// Globally unique identifier assigned to the provider by the 
        /// service provider vendor. 
        /// </summary>
        public Guid ProviderId;
        /// <summary>
        /// Unique identifier assigned by the WS2_32.DLL for each 
        /// WSAPROTOCOL_INFO structure
        /// </summary>
        public uint CatalogEntryId;
        /// <summary>
        /// WSAPROTOCOLCHAIN structure associated with the protocol
        /// </summary>
        public WsaProtocolChain ProtocolChain;
        /// <summary>
        /// Protocol version identifier.
        /// </summary>
        public int Version;
        /// <summary>
        /// Value to pass as the address family parameter to the 
        /// socket/WSASocket function in order to open a socket for this 
        /// protocol. 
        /// </summary>
        public int AddressFamily;
        /// <summary>
        /// Maximum address length, in bytes.
        /// </summary>
        public int MaxSockAddr;
        /// <summary>
        /// Minimum address length, in bytes.
        /// </summary>
        public int MinSockAddr;
        /// <summary>
        /// Value to pass as the socket type parameter to the socket
        /// function in order to open a socket for this protocol.
        /// </summary>
        public int SocketType;
        /// <summary>
        /// Value to pass as the protocol parameter to the socket
        /// function in order to open a socket for this protocol.
        /// </summary>
        public int Protocol;
        /// <summary>
        /// Maximum value that may be added to iProtocol when 
        /// supplying a value for the protocol parameter to socket 
        /// and WSASocket.
        /// </summary>
        public int ProtocolMaxOffset;
        /// <summary>
        /// Currently these values are manifest constants 
        /// (BIGENDIAN and LITTLEENDIAN) that indicate either big-endian 
        /// or little-endian with the values 0 and 1 respectively.
        /// </summary>
        public int NetworkByteOrder;
        /// <summary>
        /// Indicates the type of security scheme employed (if any).
        /// </summary>
        public int SecuritySchema;
        /// <summary>
        /// Maximum message size supported by the protocol.
        /// </summary>
        public int MessageSize;
        /// <summary>
        /// Reserved for use by service providers.
        /// </summary>
        public int ProviderReserved;
        /// <summary>
        /// Array of characters that contains a human-readable name 
        /// identifying the protocol
        /// </summary>
        [MarshalAs(UnmanagedType.ByValTStr,
            SizeConst = BluetoothHelper.WSAPROTOCOL_LEN + 1)]
        public string ProtocolName;
    }
}
